﻿using System.Collections;
using UnityEngine;

namespace Assets.XiaoXiao.Script
{
    class Move : MonoBehaviour
    {
        public float speed = 0.5f;
        public GameObject target;
        private Vector3 direction;
        private Coroutine cououtine;

        public Vector3 DirectionMove
        {
             get { return direction; }
        }
        private IEnumerator MoveTransform()
        {
            while (true)
            {
                this.target.transform.position += this.direction * Time.deltaTime * this.speed;
                yield return null;
            }
        }

        public void BeginMove()
        {
            this.cououtine = StartCoroutine(this.MoveTransform());
        }

        public void EndMove()
        {
            //TODO：
            //这里会有一个问题，方向设置为0，那原来的默认方向就错了
            this.StopCoroutine(this.cououtine);
            this.direction = Vector3.zero;
        }

        public void ObjJump()
        {
           
        }

        public void ObjAttack()
        {
            
            
        }

        public void UpdateDirection(Vector3 direction)
        {
            this.direction = direction;
        }
    }
}
